<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Http\Service\api\ShopTrolleyServer;
use App\Http\Service\Redisd;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;

class ShopTrolleyController extends Controller
{
    //

    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * 购物车添加
     */
    public function ShopTrolleyAdd(Request $request)
    {

        $data = $request->input();


        $data_true = ShopTrolleyServer::ShopTrolleyAdd($data);
        if ($data_true['code']!=200){
            return self::error('添加失败');
        }
           return self::success('添加成功');
    }


    /**
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     *  购物车前台删除
     */
    public function ShopTrolleyDelete(Request $request)
    {


        $id = $request->input('id');

        $data_true = ShopTrolleyServer::ShopTrolleyDelete($id);

        if ($data_true['code']!=200){
            return self::error('删除失败');
        }
            return self::success('删除成功');

    }



    public function ShopTrolleyUpdate(Request $request)
    {
        $id = $request->input('id');
        $data = $request->input('data');

        $data_true = ShopTrolleyServer::ShopTrolleyUpdate($id,$data);

        if ($data_true['code']!=200){
            return self::error('修改失败');
        }
            return self::success('修改成功');

    }

}
